/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.follow.FollowUpItemRecordQuestion;

public interface FollowUpItemRecordQuestionDao extends PagingAndSortingRepository<FollowUpItemRecordQuestion, Long>, JpaSpecificationExecutor<FollowUpItemRecordQuestion> {

	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItemAndRecord(String plan, String stage, String item, String record);

	@Query("select a from FollowUpItemRecordQuestion a where a.record = ?1 ")
	List<FollowUpItemRecordQuestion> getFollowUpItemRecordQuestionByRecoredCode(String recoredCode);

	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?3 ")
	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItem(String plan, String stage, String code);

	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1 ")
	List<FollowUpItemRecordQuestion> findByPlanAndStageAndItem(String code);

	@Query("select a from FollowUpItemRecordQuestion a where a.record = ?1 ")
	List<FollowUpItemRecordQuestion> findByRecord(String recordCode);

	@Query("select distinct(a.index) from FollowUpItemRecordQuestion a where a.item = ?1 ")
	List<Integer> getByItemCodeDistinctType(String itemCode);

	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1 and a.index=?2")
	List<FollowUpItemRecordQuestion> findByItemAndType(String code, int index);

	@Query("select a from FollowUpItemRecordQuestion a where a.item = ?1")
	List<FollowUpItemRecordQuestion> findByItemCode(String itemCode);

	@Query("select a from FollowUpItemRecordQuestion a where a.code = ?1")
	FollowUpItemRecordQuestion findByCode(String question);
}
